{# SPDX-License-Identifier: Apache-2.0 -#}

{% extends "admin/base.html" %}

{% block title %}Banners{% endblock %}

{% block breadcrumb %}
  <li class="breadcrumb-item active">Banners</li>
{% endblock %}

{% block content %}

<div class="card card-primary card-outline">
  {% if request.has_permission(Permissions.AdminBannerWrite) %}
  <div class="card-header">
    <a class="btn btn-primary" href="{{ request.route_path('admin.banner.create') }}"><i class="fa fa-plus"></i> Create Banner</a>
  </div>
  {% endif %}
  <div class="card-body table-responsive p-0">
    <table class="table table-hover table-striped">
      <thead>
      <tr>
        <th>Name</th>
        <th>Is active?</th>
        <th>End date</th>
        <th title="Banners are visible if active and with future end dates (UTC timezone)" data-tooltip-label="ih">Is visible now?</th>
        <th>Preview link</th>
      </tr>
      </thead>

      <tbody>
      {% for banner in banners %}
      <tr>
        <td>
          <a href="{{ request.route_path('admin.banner.edit', banner_id=banner.id) }}">{{ banner.name }}</a>
        </td>
        <td><i class="fa {% if banner.active %}fa-check text-green{% else %}fa-times{% endif %}"></i></td>
        <td>Until {{ banner.end }}</td>
        <td><i class="fa {% if banner.is_live %}fa-check text-green{% else %}fa-times{% endif %}"></i></td>
        <td><a target="_blank" rel="nofollow noopener noreferrer" href="{{ request.route_path('admin.banner.preview', banner_id=banner.id) }}">Click to preview <i class="fa-solid fa-arrow-up-right-from-square"></i></a></td>
      </tr>
      {% endfor %}
      </tbody>
    </table>

  </div>
</div>
{% endblock content %}
